import { APP_FLIGHT_PATH, callService } from '@/common/common.js'


export function searchCustomers(params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customers'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchCustomerDetails(params, cbDone, cbAlways) {
  const url = APP_FLIGHT_PATH + '/customer-details'
  callService(url, {
    data: params,
    cbDone: cbDone,
    cbAlways: cbAlways
  })
}

export function searchCustomerDetail(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id
  callService(url, {
    cbDone: cbDone
  })
}

export function searchTodoCustomer(cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/todos'
  callService(url, {
    cbDone: cbDone
  })
}

export function searchPossibleCustomers(params, cbDone) {
  const url = APP_FLIGHT_PATH + '/possibleCustomers'
  callService(url, {
    contentType: 'application/json',
    data: params,
    cbDone: cbDone
  })
}

export function searchEnterpriseById(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/admin/enterprise/' + id
  callService(url, {
    cbDone: cbDone
  })
}

export function searchCustomerByEnterpriseId(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/admin/enterprise/' + id + '/customer'
  callService(url, {
    cbDone: cbDone
  })
}

export function searchDepartmentsByCustomerId(customerId, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/departments'
  callService(url, {
    cbDone: cbDone
  })
}

export function searchCustomerNotes(params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/notes'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchNotesByCustomer(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id + '/notes'
  callService(url, {
    cbDone: cbDone
  })
}


export function searchServiceTemplateByCustomer(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id + '/serviceTemplate'
  callService(url, {
    type: 'get',
    cbDone: cbDone
  })
}


export function createCustomerNote(params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/note/create'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function deleteCustomerNote(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/note/' + id + '/delete'
  callService(url, {
    cbDone: cbDone
  })
}

export function createCustomer(params, cbDone, cbAlways, cbFail) {
  const url = APP_FLIGHT_PATH + '/customer'
  callService(url, {
    contentType: 'application/json',
    data: params,
    cbDone: cbDone,
    cbAlways: cbAlways,
    cbFail: cbFail
  })
}

export function generateCustomerByEnterpriseId(id, cbDone, cbAlways, cbFail) {
  const url = APP_FLIGHT_PATH + '/customer/enterprise/' + id
  callService(url, {
    cbDone: cbDone,
    cbAlways: cbAlways,
    cbFail: cbFail
  })
}

export function getSettlementTypeDesc(val) {
  switch (val) {
    case 1: return '次日结'
    case 2: return '周结'
    case 3: return '月结'
    case 0: return '(待定)'
    default: return val
  }
}

export function getApprovalTypeDesc(val) {
  switch (val) {
    case 1: return '电话'
    case 2: return '短信'
    case 3: return '邮件'
    case 4: return '微信'
    default: return val
  }
}

export function getItineraryTypeDesc(val) {
  switch (val) {
    case 0: return '不'
    case 1: return '行程单'
    case 2: return '发票'
    case 3: return '信息单'
    default: return val
  }
}

export function saveCustomerSmsMode(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/smsMode'
  callService(url, {
    data: params,
    // contentType: 'application/json',
    cbDone: cbDone
  })
}

export function searchCustomerDiscountInfo(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id + '/discount'
  callService(url, {
    type: 'get',
    cbDone: cbDone
  })
}

export function saveCustomerDiscountInfo(id, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id + '/discount'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchCustomerAvCountInfo(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id + '/avCountInfo'
  callService(url, {
    type: 'get',
    cbDone: cbDone
  })
}

export function saveCustomerAvCountInfo(id, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id + '/avCountInfo'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchCustomerFlightDiscounts(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id + '/flightDiscounts'
  callService(url, {
    type: 'get',
    cbDone: cbDone
  })
}

export function saveCustomerFlightDiscount(id, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + id + '/flightDiscount'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}


export function createDepartment(params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/department'
  callService(url, {
    data: params,
    contentType: 'application/json',
    cbDone: cbDone
  })
}

export function searchDepartments(params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customers/departments'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchDepartment(id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/department/' + id
  callService(url, {
    type: 'get',
    cbDone: cbDone
  })
}

export function searchCustomerPositions(customerId, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/positions'
  callService(url, {
    type: 'get',
    cbDone: cbDone
  })
}

export function saveCustomerPosition(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/position'
  callService(url, {
    data: params,
    contentType: 'application/json',
    cbDone: cbDone
  })
}


export function saveCustomerTravelZone(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/zone'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchCustomerTravelZones(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/zones'
  callService(url, {
    type: 'get',
    data: params,
    cbDone: cbDone
  })
}

//保存酒店差旅政策
export function saveHotelTp(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/hotel'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchHotelTps(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/hotels'
  callService(url, {
    type: 'get',
    data: params,
    cbDone: cbDone
  })
}

export function deleteHotelTp(customerId, id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/hotel/' + id
  callService(url, {
    type: 'delete',
    cbDone: cbDone
  })
}

//保存机票差旅政策
export function saveFlightTp(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/flight'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchFlightTps(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/flights'
  callService(url, {
    type: 'get',
    data: params,
    cbDone: cbDone
  })
}

export function deleteFlightTp(customerId, id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/flight/' + id
  callService(url, {
    type: 'delete',
    cbDone: cbDone
  })
}

//保存用车差旅政策
export function saveCarTp(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/car'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchCarTps(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/cars'
  callService(url, {
    type: 'get',
    data: params,
    cbDone: cbDone
  })
}

export function deleteCarTp(customerId, id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/car/' + id
  callService(url, {
    type: 'delete',
    cbDone: cbDone
  })
}

//保存火车票差旅政策
export function saveTrainTp(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/train'
  callService(url, {
    data: params,
    cbDone: cbDone
  })
}

export function searchTrainTps(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/trains'
  callService(url, {
    type: 'get',
    data: params,
    cbDone: cbDone
  })
}

export function deleteTrainTp(customerId, id, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/tp/train/' + id
  callService(url, {
    type: 'delete',
    cbDone: cbDone
  })
}


export function searchCustomerLoginInfos(customerId, params, cbDone) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/loginInfos'
  callService(url, {
    type: 'get',
    data: params,
    cbDone: cbDone
  })
}

//保存差旅审批人
export function saveCustomerApprover(customerId, departmentId, params, cbDone, cbAlways) {
  const url = APP_FLIGHT_PATH + '/customer/' + customerId + '/department/' + departmentId + '/approver'
  callService(url, {
    data: params,
    cbDone: cbDone,
    cbAlways: cbAlways
  })
}

//删除差旅审批人
export function deleteCustomerApprover(approverId, cbDone, cbAlways) {
  const url = APP_FLIGHT_PATH + '/customer/department/approver/' + approverId
  callService(url, {
    type: 'delete',
    cbDone: cbDone,
    cbAlways: cbAlways
  })
}

